package com.situ.web.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.situ.web.service.IStudentService;
import com.situ.web.service.impl.StudentServiceImpl;

public class DeleteStudentServlet extends HttpServlet{
	private IStudentService studentService = new StudentServiceImpl();
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String id = req.getParameter("id");
		boolean isSuccess = studentService.deleteById(Integer.parseInt(id));
		
		//resp.sendRedirect(req.getContextPath() + "/findAllStudent");
		resp.sendRedirect(req.getContextPath() + "/pageList");
		
		/*resp.setContentType("text/html;charset=utf-8");
		PrintWriter writer = resp.getWriter();
		if (isSuccess) {
			writer.println("删除成功");
		} else {
			writer.println("删除失败");
		}
		writer.close();*/
	}
}
